package com.ruoyi.sycs.controller;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaCheckLogin;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.sycs.domain.vo.SycsDataDetailSyVo;
import com.ruoyi.sycs.domain.bo.SycsDataDetailSyBo;
import com.ruoyi.sycs.service.ISycsDataDetailSyService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 试验数据设置明细-水银/空气粘度
 *
 * @author tll
 * @date 2024-04-09
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/sycs/dataDetailSy")
public class SycsDataDetailSyController extends BaseController {

    private final ISycsDataDetailSyService iSycsDataDetailSyService;

    /**
     * 查询试验数据设置明细-水银/空气粘度列表
     */
    @SaCheckLogin
    @GetMapping("/list")
    public TableDataInfo<SycsDataDetailSyVo> list(SycsDataDetailSyBo bo, PageQuery pageQuery) {
        return iSycsDataDetailSyService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出试验数据设置明细-水银/空气粘度列表
     */
    @SaCheckLogin
    @Log(title = "试验数据设置明细-水银/空气粘度", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(SycsDataDetailSyBo bo, HttpServletResponse response) {
        List<SycsDataDetailSyVo> list = iSycsDataDetailSyService.queryList(bo);
        ExcelUtil.exportExcel(list, "试验数据设置明细-水银/空气粘度", SycsDataDetailSyVo.class, response);
    }

    /**
     * 获取试验数据设置明细-水银/空气粘度详细信息
     *
     * @param deId 主键
     */
    @SaCheckLogin
    @GetMapping("/{deId}")
    public R<SycsDataDetailSyVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long deId) {
        return R.ok(iSycsDataDetailSyService.queryById(deId));
    }

    /**
     * 新增试验数据设置明细-水银/空气粘度
     */
    @SaCheckLogin
    @Log(title = "试验数据设置明细-水银/空气粘度", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody SycsDataDetailSyBo bo) {
        return toAjax(iSycsDataDetailSyService.insertByBo(bo));
    }

    /**
     * 修改试验数据设置明细-水银/空气粘度
     */
    @SaCheckLogin
    @Log(title = "试验数据设置明细-水银/空气粘度", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody SycsDataDetailSyBo bo) {
        return toAjax(iSycsDataDetailSyService.updateByBo(bo));
    }

    /**
     * 删除试验数据设置明细-水银/空气粘度
     *
     * @param deIds 主键串
     */
    @SaCheckLogin
    @Log(title = "试验数据设置明细-水银/空气粘度", businessType = BusinessType.DELETE)
    @DeleteMapping("/{deIds}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] deIds) {
        return toAjax(iSycsDataDetailSyService.deleteWithValidByIds(Arrays.asList(deIds), true));
    }
}
